/*
 * Created by JFormDesigner on Mon Apr 03 09:29:16 CST 2023
 */

package com.canteen.gui.mainform;

import com.canteen.gui.customerform.CustomerForm;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

/**
 * @author s303teacher
 */
public class CanteenMainForm extends JFrame {
    public CanteenMainForm() {
        initComponents();
    }

    private void addCustomer(ActionEvent e) {
        // TODO add your code here
        CustomerForm customerForm = new CustomerForm();
        customerForm.setVisible(true);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        canteenManagementMenuBar = new JMenuBar();
        fileMenu = new JMenu();
        menuItemOrderImport = new JMenuItem();
        menuItemOrderExport = new JMenuItem();
        menuItemExit = new JMenuItem();
        userMenu = new JMenu();
        menuItemAddUser = new JMenuItem();
        menuItemSearchUser = new JMenuItem();
        customerMenu = new JMenu();
        menuItemAddCustomer = new JMenuItem();
        menuItemSearchCustomer = new JMenuItem();
        dishesMenu = new JMenu();
        menuItemAddDishes = new JMenuItem();
        menuItemSearchDishes = new JMenuItem();
        dishesListMenu = new JMenu();
        menuItemAddMenu = new JMenuItem();
        menuItemSearchMenu = new JMenuItem();
        orderingMenu = new JMenu();
        menuItemAddOrder = new JMenuItem();
        menuItemSearchOrder = new JMenuItem();
        todayOrderLabel = new JLabel();
        todayMenuDetailLabel = new JLabel();
        scrollPane1 = new JScrollPane();
        todayOrderTable = new JTable();
        scrollPane2 = new JScrollPane();
        todayMenuDetailList = new JList();
        printOrderButton = new JButton();
        printerSettingButton = new JButton();
        todayMenuSettingButton = new JButton();
        menuCreateButton = new JButton();

        //======== this ========
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("\u6559\u5de5\u98df\u5802\u8ba2\u5355\u5e73\u53f0");
        setResizable(false);
        var contentPane = getContentPane();
        contentPane.setLayout(null);

        //======== canteenManagementMenuBar ========
        {

            //======== fileMenu ========
            {
                fileMenu.setText("\u6587\u4ef6");

                //---- menuItemOrderImport ----
                menuItemOrderImport.setText("\u8ba2\u5355\u5bfc\u5165");
                fileMenu.add(menuItemOrderImport);

                //---- menuItemOrderExport ----
                menuItemOrderExport.setText("\u8ba2\u5355\u5bfc\u51fa");
                fileMenu.add(menuItemOrderExport);

                //---- menuItemExit ----
                menuItemExit.setText("\u9000\u51fa");
                fileMenu.add(menuItemExit);
            }
            canteenManagementMenuBar.add(fileMenu);

            //======== userMenu ========
            {
                userMenu.setText("\u7528\u6237");

                //---- menuItemAddUser ----
                menuItemAddUser.setText("\u7528\u6237\u65b0\u589e");
                userMenu.add(menuItemAddUser);

                //---- menuItemSearchUser ----
                menuItemSearchUser.setText("\u7528\u6237\u67e5\u8be2");
                userMenu.add(menuItemSearchUser);
            }
            canteenManagementMenuBar.add(userMenu);

            //======== customerMenu ========
            {
                customerMenu.setText("\u987e\u5ba2");

                //---- menuItemAddCustomer ----
                menuItemAddCustomer.setText("\u987e\u5ba2\u65b0\u589e");
                menuItemAddCustomer.addActionListener(e -> addCustomer(e));
                customerMenu.add(menuItemAddCustomer);

                //---- menuItemSearchCustomer ----
                menuItemSearchCustomer.setText("\u987e\u5ba2\u67e5\u8be2");
                customerMenu.add(menuItemSearchCustomer);
            }
            canteenManagementMenuBar.add(customerMenu);

            //======== dishesMenu ========
            {
                dishesMenu.setText("\u83dc\u54c1");

                //---- menuItemAddDishes ----
                menuItemAddDishes.setText("\u83dc\u54c1\u65b0\u589e");
                dishesMenu.add(menuItemAddDishes);

                //---- menuItemSearchDishes ----
                menuItemSearchDishes.setText("\u83dc\u54c1\u67e5\u8be2");
                dishesMenu.add(menuItemSearchDishes);
            }
            canteenManagementMenuBar.add(dishesMenu);

            //======== dishesListMenu ========
            {
                dishesListMenu.setText("\u83dc\u5355");

                //---- menuItemAddMenu ----
                menuItemAddMenu.setText("\u83dc\u5355\u65b0\u589e");
                dishesListMenu.add(menuItemAddMenu);

                //---- menuItemSearchMenu ----
                menuItemSearchMenu.setText("\u83dc\u5355\u67e5\u8be2");
                dishesListMenu.add(menuItemSearchMenu);
            }
            canteenManagementMenuBar.add(dishesListMenu);

            //======== orderingMenu ========
            {
                orderingMenu.setText("\u8ba2\u5355");

                //---- menuItemAddOrder ----
                menuItemAddOrder.setText("\u8ba2\u5355\u65b0\u589e");
                orderingMenu.add(menuItemAddOrder);

                //---- menuItemSearchOrder ----
                menuItemSearchOrder.setText("\u8ba2\u5355\u67e5\u8be2");
                orderingMenu.add(menuItemSearchOrder);
            }
            canteenManagementMenuBar.add(orderingMenu);
        }
        setJMenuBar(canteenManagementMenuBar);

        //---- todayOrderLabel ----
        todayOrderLabel.setText("\u4eca\u65e5\u8ba2\u5355\uff1a");
        contentPane.add(todayOrderLabel);
        todayOrderLabel.setBounds(new Rectangle(new Point(30, 40), todayOrderLabel.getPreferredSize()));

        //---- todayMenuDetailLabel ----
        todayMenuDetailLabel.setText("\u4eca\u65e5\u83dc\u5355\uff1a");
        contentPane.add(todayMenuDetailLabel);
        todayMenuDetailLabel.setBounds(new Rectangle(new Point(470, 45), todayMenuDetailLabel.getPreferredSize()));

        //======== scrollPane1 ========
        {

            //---- todayOrderTable ----
            todayOrderTable.setModel(new DefaultTableModel(
                new Object[][] {
                    {null, null, null, null, null, null},
                    {null, null, null, null, null, null},
                },
                new String[] {
                    "\u5e8f\u53f7", "\u8ba2\u5355\u53f7", "\u59d3\u540d", "\u624b\u673a", "\u4efd\u6570", "\u521b\u5efa\u65f6\u95f4"
                }
            ) {
                Class<?>[] columnTypes = new Class<?>[] {
                    Long.class, String.class, String.class, String.class, Integer.class, Date.class
                };
                @Override
                public Class<?> getColumnClass(int columnIndex) {
                    return columnTypes[columnIndex];
                }
            });
            {
                TableColumnModel cm = todayOrderTable.getColumnModel();
                cm.getColumn(0).setPreferredWidth(50);
            }
            scrollPane1.setViewportView(todayOrderTable);
        }
        contentPane.add(scrollPane1);
        scrollPane1.setBounds(35, 75, 425, 190);

        //======== scrollPane2 ========
        {
            scrollPane2.setViewportView(todayMenuDetailList);
        }
        contentPane.add(scrollPane2);
        scrollPane2.setBounds(505, 75, 250, 190);

        //---- printOrderButton ----
        printOrderButton.setText("\u6253\u5355");
        contentPane.add(printOrderButton);
        printOrderButton.setBounds(new Rectangle(new Point(250, 280), printOrderButton.getPreferredSize()));

        //---- printerSettingButton ----
        printerSettingButton.setText("\u6253\u5355\u673a\u8bbe\u7f6e");
        contentPane.add(printerSettingButton);
        printerSettingButton.setBounds(new Rectangle(new Point(330, 280), printerSettingButton.getPreferredSize()));

        //---- todayMenuSettingButton ----
        todayMenuSettingButton.setText("\u4eca\u65e5\u83dc\u5355\u8bbe\u7f6e");
        contentPane.add(todayMenuSettingButton);
        todayMenuSettingButton.setBounds(new Rectangle(new Point(530, 275), todayMenuSettingButton.getPreferredSize()));

        //---- menuCreateButton ----
        menuCreateButton.setText("\u83dc\u5355\u521b\u5efa");
        contentPane.add(menuCreateButton);
        menuCreateButton.setBounds(new Rectangle(new Point(665, 275), menuCreateButton.getPreferredSize()));

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(795, 385);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JMenuBar canteenManagementMenuBar;
    private JMenu fileMenu;
    private JMenuItem menuItemOrderImport;
    private JMenuItem menuItemOrderExport;
    private JMenuItem menuItemExit;
    private JMenu userMenu;
    private JMenuItem menuItemAddUser;
    private JMenuItem menuItemSearchUser;
    private JMenu customerMenu;
    private JMenuItem menuItemAddCustomer;
    private JMenuItem menuItemSearchCustomer;
    private JMenu dishesMenu;
    private JMenuItem menuItemAddDishes;
    private JMenuItem menuItemSearchDishes;
    private JMenu dishesListMenu;
    private JMenuItem menuItemAddMenu;
    private JMenuItem menuItemSearchMenu;
    private JMenu orderingMenu;
    private JMenuItem menuItemAddOrder;
    private JMenuItem menuItemSearchOrder;
    private JLabel todayOrderLabel;
    private JLabel todayMenuDetailLabel;
    private JScrollPane scrollPane1;
    private JTable todayOrderTable;
    private JScrollPane scrollPane2;
    private JList todayMenuDetailList;
    private JButton printOrderButton;
    private JButton printerSettingButton;
    private JButton todayMenuSettingButton;
    private JButton menuCreateButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
